﻿using FastReport;
using FastReport.DevComponents.DotNetBar.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static WinFormsApp1.Leo.week02.SlaughteredUpdate;
using WinFormsApp1.Common;

namespace WinFormsApp1.Leo.ListWeeks03
{
    public partial class Sale : Form
    {
        private int salesDetailsId;
        public Sale(int SalesDetailsId)
        {
            InitializeComponent();
            this.salesDetailsId = SalesDetailsId;
        }

        private async void Sale_Load(object sender, EventArgs e)
        {
            SalesDetailsMan salesDetailsMan = new(salesDetailsId);

            var items = await HttpClientHelper.RequestUrl<SalesDetailsMan, ApiResult<SalesDetailss>>(URLCommon.Url2, "/WeekListOne_Leo/GeSaleDetaiMang", HttpClientHelper.MethodType.POST, salesDetailsMan);

            this.label.Text = Convert.ToString(items.Data.SalesDetailsDate.ToString("yyyy年MM月dd日"));
            this.label8.Text = items.Data.CustomerNickname;
            this.label11.Text = Convert.ToString(items.Data.SalesDetailsState);
            this.label7.Text = items.Data.SalesDetailsOrderNumber.ToString();
            this.label9.Text = items.Data.SalesDetailsOrderNum.ToString();

            if (label11.Text == "True")
            {
                label11.Text = "正在运行";
            }
            else
            {
                label11.Text = "已停运";
            }
        }

        public record SalesDetailsMan(int SalesDetailsId);

        public class SalesDetailss
        {

            public int SalesDetailsId { get; set; }

            /// <summary>
            /// 发货日期
            /// </summary>
            public DateTime SalesDetailsDate { get; set; }

            /// <summary>
            /// 客户名称
            /// </summary>
            public string CustomerNickname { get; set; }

            /// <summary>
            /// 订货件数
            /// </summary>
            public string SalesDetailsOrderNumber { get; set; }

            /// <summary>
            /// 订货数量
            /// </summary>
            public string SalesDetailsOrderNum { get; set; }

            /// <summary>
            /// 订单状态
            /// </summary>
            public bool SalesDetailsState { get; set; }

            /// <summary>
            /// 是否删除
            /// </summary>
            public bool IsDelete { get; set; } = false;
        }

    }
}
